<extend name="Base/common"/>

<block name="body">
	<div class="mui-content mine_top">
	    <div class="mine_avator">
    		<if condition="$userinfo['user_avatar'] eq ''">
    		<img src="__IMG__/default.jpg">
    		<else />
    		<img src="{$userinfo.user_avatar}">
    		</if>
            <input type="file" id="file_avator" class="mui-hidden">
	    </div>
	    <div class="mine_info">
	    	<li>{$userinfo.nickname}</li>
	    	<li>余额：&yen;{$userinfo.amount}</li>
	    	<li>中奖次数:{$win_num}次</li>
	    </div>
	</div>
    <ul class="mui-table-view mine_menu">
        <li class="mui-table-view-cell">
            <a class="mui-navigate-right" href="{:U('mine_wallet')}">
            	<div class="menu_icon"><img src="__IMG__/mine_card.png"></div>
            	<div class="menu_title">我的钱包</div>
            </a>
        </li>
        <li class="mui-table-view-cell">
            <a class="mui-navigate-right" href="{:U('mine_coin')}">
            	<div class="menu_icon"><img src="__IMG__/mine_wallet.png"></div>
            	<div class="menu_title">我的钻石</div>
            </a>
        </li>
        <li class="mui-table-view-cell">
            <a class="mui-navigate-right" href="{:U('mine_win')}">
            	<div class="menu_icon"><img src="__IMG__/mine_win.png"></div>
            	<div class="menu_title">中奖记录</div>
            </a>
        </li>
        <li class="mui-table-view-cell">
            <a class="mui-navigate-right" href="{:U('mine_join')}">
            	<div class="menu_icon"><img src="__IMG__/mine_join.png"></div>
            	<div class="menu_title" style="margin-top:auto;">参与记录</div>
            </a>
        </li>
        <li class="mui-table-view-cell">
            <a class="mui-navigate-right" href="{:U('mine_history')}">
                <div class="menu_icon"><img src="__IMG__/mine_history.png"></div>
                <div class="menu_title" style="margin-top: auto;">历史发布记录</div>
            </a>
        </li>
        <li class="mui-table-view-cell">
            <a class="mui-navigate-right" href="{:U('mine_page')}">
                <div class="menu_icon"><img src="__IMG__/mine_card.png"></div>
                <div class="menu_title" style="margin-top: auto;">兑换/提现</div>
            </a>
        </li>
        <li class="mui-table-view-cell">
            <a class="mui-navigate-right" href="{:U('logout')}">
                <div class="menu_icon"><img src="__IMG__/mine_card.png"></div>
                <div class="menu_title" style="margin-top: auto;">切换账号</div>
            </a>
        </li>
    </ul>
	<div class="float_add_snatch">
		<a href="{:U('snatch/add')}">
			<img src="__IMG__/add_snatch.png">
		</a>
	</div>
	<nav class="mui-bar mui-bar-tab">
	    <a class="mui-tab-item" href="{:U('index/index')}">
	        <span class="mui-icon icon-renpin"></span>
	        <span class="mui-tab-label">人品大爆发</span>
	    </a>
	    <a class="mui-tab-item" href="{:U('snatch/index')}">
	        <span class="mui-icon icon-huodong"></span>
	        <span class="mui-tab-label">全部活动</span>
	    </a>
	    <a class="mui-tab-item mui-active" href="{:U('mine/index')}">
	        <span class="mui-icon icon-mine"></span>
	        <span class="mui-tab-label">我的</span>
	    </a>
	</nav>
</block>
<block name="script">
	<script type="text/javascript">
		mui('.mui-bar-tab').on('tap','a',function(){
			var url = this.attributes['href'].value;
			mui.openWindow({
				url:url
			});
		});
        $(".mine_avator").on("tap",function(){
            $("#file_avator").click();
        })
        $("#file_avator").change(function(){
            var jsonData = new FormData();  
            jsonData.append('avator', $(this)[0].files[0]);  
            $.ajax({  
                url : "{:U('updateAvator')}",  
                type : "POST",  
                enctype: 'multipart/form-data',
                dataType: "json",
                data : jsonData,
                contentType: false,
                processData: false, 
                success:function(result){
                    mui.confirm(result.info,'提示',['确定'],function(e){
                        if (result.url != '') {
                            location.href = result.url;
                        }else{
                            location.reload();
                        }
                    })
                },
                error:function(data){
                    mui.confirm(result.info,'提示',['确定'],function(e){
                        location.reload();
                    })
                }
            })
        })
	</script>
</block>